﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Sockets;
using System.Net;

namespace Touchless.Demo
{
    public partial class Networking : Form
    {
        myServer server;
        myClient client;
        int windowWidth, windowHeight;
        public readonly int msgSize = 12;

        public Networking(int displayWindowWidth, int displayWindowHeight)
        {
            windowWidth = displayWindowWidth;
            windowHeight = displayWindowHeight;
            InitializeComponent();
        }

        /// <summary>
        /// Runs in server mode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ServerButton_Click(object sender, EventArgs e)
        {
            toggleControls(false);

            server = new myServer(this, windowWidth, windowHeight);
        }

        /// <summary>
        /// Enables/Disables the controls in the GUI.
        /// </summary>
        /// <param name="enabled"></param>
        public void toggleControls(bool enabled)
        {
            ServerButton.Enabled = ClientButton.Enabled = secondsDelayUpDown.Enabled = millisecondsDelayUpDown.Enabled = enabled;
        }

        /// <summary>
        /// Runs in client mode
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ClientButton_Click(object sender, EventArgs e)
        {
            toggleControls(false);
            client = new myClient(this, windowWidth, windowHeight);
        }

        public void MessageBoxShow(string str)
        {
            MessageBox.Show(str);
        }
    }
}
